home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / Abalone 1.4.2 / src / InsideMac.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-21  |  2.0 KB  |  131 lines  |  [TEXT/MPS ]

  1. #include "InsideMac.h"
  2.  
  3. #include <Events.h>
  4. #include <GestaltEqu.h>
  5. #include <OSUtils.h>
  6. #include <QuickDraw.h>
  7. #include <PPCToolbox.h>
  8. #include <Traps.h>
  9.  
  10.  
  11. #if defined(__MWERKS__)
  12. #pragma segment __%Main
  13. #else
  14. #pragma segment Main
  15. #endif
  16.  
  17.  
  18. boolean
  19. TrapAvailable (short theTrap)
  20. {
  21.     TrapType tType;
  22.     
  23.     if ((tType = GetTrapType (theTrap)) == ToolTrap)
  24.     {
  25.         theTrap &= 0x7FF;
  26.         if (theTrap >= NumToolboxTraps())
  27.             theTrap = _Unimplemented;
  28.     }
  29.     return NGetTrapAddress (theTrap, tType) != NGetTrapAddress (_Unimplemented, ToolTrap);
  30. }
  31.  
  32.  
  33.  
  34. TrapType
  35. GetTrapType (short theTrap)
  36. {
  37.     return theTrap & 0x800 > 0 ? ToolTrap : OSTrap;
  38. }
  39.  
  40.  
  41.  
  42. boolean
  43. GestaltAvailable (void)
  44. {
  45.     return TrapAvailable (0xA1AD);
  46. }
  47.  
  48.  
  49.  
  50. boolean
  51. System7Available (void)
  52. {
  53.     boolean available = false;
  54.     
  55.     if (GestaltAvailable())
  56.     {
  57.         long result;
  58.         
  59.         Gestalt (gestaltSystemVersion, & result);
  60.         available = ((result >> 8) & 0xFF) >= 7;
  61.     }
  62.     return available;
  63. }
  64.  
  65.  
  66.  
  67. boolean
  68. ColorQDAvailable (void)
  69. {
  70.     static boolean firstTime = true;
  71.     static boolean available = false;
  72.     
  73.     if (firstTime)
  74.     {
  75.         long result;
  76.         
  77.         firstTime = false;
  78.         if (GestaltAvailable())
  79.         {
  80.             Gestalt (gestaltQuickdrawVersion, & result);
  81.             available = (result & 0xFFFF) >= gestalt8BitQD;
  82.         }
  83.     }
  84.     return available;
  85. }
  86.  
  87.  
  88.  
  89. short
  90. NumToolboxTraps (void)
  91. {
  92.     return NGetTrapAddress (0xAA6E, ToolTrap) == NGetTrapAddress (_InitGraf, ToolTrap)
  93.     ?    0X200
  94.     :    0X400;
  95. }
  96.  
  97.  
  98. OSErr
  99. InitPPC (void)
  100. {    
  101.     long    PPCAttributes;
  102.     OSErr    error;
  103.     
  104.     if ((error = Gestalt (gestaltPPCToolboxAttr, &PPCAttributes)) == noErr)
  105.     {    
  106.         if (! (PPCAttributes & gestaltPPCSupportsRealTime))
  107.         {
  108.             error = PPCInit();
  109.         //    Next line in IM was an error? Comment did not match code!
  110.         //    error = Gestalt (gestaltPPCToolboxAttr, &PPCAttributes); 
  111.         }
  112.         if (PPCAttributes & gestaltPPCSupportsOutGoing)
  113.         {
  114.         //    Ports can be opened to the outside world
  115.         }
  116.         else
  117.         {
  118.         //    Appletalk disabled?
  119.         }
  120.         if (PPCAttributes & gestaltPPCSupportsIncoming)
  121.         {
  122.         //    Outside world can see location names
  123.         }
  124.         else
  125.         {
  126.         //    Program linking disabled?
  127.         }
  128.     }
  129.     return error;
  130. }
  131.